#include"../source/tcp_server.hpp"

void OnConnected(const PtrConnection& conn){
    DLOG("NEW CONNECTION:%p",conn.get());
}
void OnClosed(const PtrConnection& conn){
    DLOG("CLOSE CONNECTION:%p",conn.get());
}

void MessageHandler(const PtrConnection&conn,Buffer*buffer){
    DLOG("%s",buffer->ReadPosition());
    buffer->MoveReadOffset(buffer->ReadAlbeSize());
    std::string str="hello";
    conn->Send(str.c_str(),str.size());
    // conn->Shutdown();
}
int main()
{
    TcpServer srv(8080);
    srv.SetThreadCount(3);
    // srv.EnableInactiveRelease(10);
    srv.SetConnectedCallback(OnConnected);
    srv.SetMessageCallback(MessageHandler);
    srv.SetClosedCallback(OnClosed);
    srv.Start();

    return 0;
}